package org.chris.kotlinsample

import android.view.MenuItem
import com.example.zoulx.myapplication.BaseActivity
import kotlinx.android.synthetic.main.activity_main.*
import org.chris.kotlinsample.ui.main.Tab0Fragment

class MainActivity : BaseActivity() {
    override fun onResultLayoutResId(): Int = R.layout.activity_main

    override fun hasTitle(): Boolean =false

    override fun onInit() {

    }

    override fun onInitLayout() {
        tabViewPager!!.setData(supportFragmentManager, Tab0Fragment(), TestFragment(), TestFragment(), TestFragment(), TestFragment())
        tabViewPager!!.setupBottomNavigationView(bottomNavigationView)
        bottomNavigationView.setOnNavigationItemSelectedListener { item: MenuItem ->
            when (item.itemId) {
                R.id.navigation0 -> {
                    tabViewPager!!.currentItem = 0
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation1 -> {
                    tabViewPager!!.currentItem = 1
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation2 -> {
                    tabViewPager!!.currentItem = 2
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation3 -> {
                    tabViewPager!!.currentItem = 3
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation4 -> {
                    tabViewPager!!.currentItem = 4
                    return@setOnNavigationItemSelectedListener true
                }
            }
            false
        }
    }

    override fun start() {

    }

}